#include<stdio.h>
#include<conio.h>
#define FILEINP "SPIRAL.INP"
#define FILEOUT "SPIRAL.OUT"
long long abs(long long x){return x>0?x:-x;}
long long get(long long x,long long y){
    long long z=abs(x)>abs(y)?abs(x):abs(y);
    if(y==z)return 4*z*z-z-x+1;
    if(-y==z)return 4*z*z+3*z+x+1;
    if(x==z)return 4*z*z-3*z+y+1;
    if(-x==z)return 4*z*z+z-y+1;
    return 0;
}
long long total(long long t){
    long i;
    static long long sum[]={0,   9,  189l,	2889l,   38889l,	488889ll,	5888889ll,	688888890ll,	788888889ll,	8888888889ll};
    static long long max[]={1,   10, 100,   1000,    10000l,    100000l,    1000000l,   10000000l,      100000000l,     1000000000ll};
    for(i=9;i>=0;i--)if(t>=max[i])break;
    return (i+1)*(t-max[i]+1)+sum[i];
}
long long minValue(long long x){
    long long min=0,max=1099511627776ll,tg;
    do{
        tg=(min+max)/2;
        if(total(tg)>=x)max=tg;
        else min=tg;
    }while(max-min>1);
    return min;
}
int getChar(long long x,long long i){
    long long max[]={0,0,10,100,1000,10000l,100000l,1000000ll,10000000ll,100000000ll,1000000000ll};
    long long j=10;
    while(max[j]>x)j--;
    for(j-=i;j>=1;j--)x/=10;
    return x%10;
}
int main(){
    long p,x,y;
    FILE *fp=fopen(FILEINP,"r");
    fscanf(fp,"%ld%ld%ld",&p,&x,&y);
    fclose(fp);
    fp=fopen(FILEOUT,"w");
    long long a=get(x,y);
    long long b=minValue(a);
    
    if(p==1)fprintf(fp,"%lld",b);
    else fprintf(fp,"%d",getChar(b+1,a-total(b)));
    fclose(fp);
    getch();
    return 0;
}
